<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>预收管理</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <script type="text/javascript">
  //编写自定义JS代码

  $(document).ready(function() {

      //绑定下拉框change事件，当下来框改变时调用 SelectChange()方法
      $("select[name='cusCode']").change(function() { SelectChange(); });

  })

  function SelectChange() {

      //获取下拉框选中项的text属性值

      var selectText = $("select[name='cusCode']").find("option:selected").text();



      //获取下拉框选中项的value属性值

      var selectValue = $("select[name='cusCode']").val();

      console.log(selectValue);

      $("select[name='by1']").find("option").remove();


      //加载工地
      var url = "tKpGongdiController.do?getGongdiList&cusCode="+selectValue;
      $.ajax({
          url:url,
          type:"GET",
          dataType:"JSON",
          async: false,
          success:function(data){
              if(data.success){
                  var gongdiList = data.attributes.gongdiList;
                  if(gongdiList.length > 0){
                      for(var i=0;i<gongdiList.length;i++){
                          var value = gongdiList[i].value;
                          var text = gongdiList[i].text;

                          $("select[name='by1']").append("<option value='"+value+"'>"+text+"</option>");
                      }
                  }

              }
          }
      });

  }

  function smalltoBIG(smallID,bigID)
  {
      var aNum=$('#'+smallID).val();
      var n=aNum;
      var fraction = ['角', '分'];
      var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
      var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟']  ];
      var head = n < 0? '欠': '';
      n = Math.abs(n);

      var s = '';

      for (var i = 0; i < fraction.length; i++)
      {
          s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
      }
      s = s || '整';
      n = Math.floor(n);

      for (var i = 0; i < unit[0].length && n > 0; i++)
      {
          var p = '';
          for (var j = 0; j < unit[1].length && n > 0; j++)
          {
              p = digit[n % 10] + unit[1][j] + p;
              n = Math.floor(n / 10);
          }
          s = p.replace(/(零.)*零$/, '').replace(/^$/, '零')  + unit[0][i] + s;
      }
      //return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');
      $('#'+bigID).val(head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整'));
  }

  </script>
 </head>
 <body>
  <t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="tKpYushouController.do?doAdd" >
					<input id="id" name="id" type="hidden" value="${tKpYushouPage.id }"/>
	  <%--<input id="cusCode" name="cusCode" type="hidden" value="${tKpYushouPage.cusCode }"/>--%>

	  <table style="width: 600px;" cellpadding="0" cellspacing="1" class="formtable">
				<tr>
					<td align="right">
						<label class="Validform_label">
							类型:
						</label>
					</td>
					<td class="value">
						<input id="ysType" readonly="readonly" name="ysType" type="text" style="width: 150px" class="inputxt" value="${ysType}"   ignore="ignore" />

						<%--<t:dictSelect  field="ysType" type="list"  typeGroupCode="ys_type"  defaultVal="${ysType}" hasLabel="false"  title="预收类型" ></t:dictSelect>--%>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">类型</label>
						</td>


					<td align="right">
						<label class="Validform_label">
							客户名称:
						</label>
					</td>
					<td class="value">
						<t:dictSelect field="cusCode"  dictTable="t_kp_cus"   dictField="cus_code" dictText="cus_name" title="客户名称"></t:dictSelect>
					<%--<input id="cusName" name="cusName" type="text" style="width: 150px" class="inputxt" datatype="*"    ignore="checked"  onclick="popupClick(this,'cus_code,cus_name','cusCode,cusName','pop_kp_cus')"/>--%>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">客户名称</label>
						</td>
				</tr>

		  <tr>
			  <td align="right">
				  <label class="Validform_label">
					 承建单位:
				  </label>
			  </td>
			  <td class="value">
				  <t:dictSelect extendJson="{datatype:'*'}"  field="by1"  dictTable="t_kp_gongdi"   dictField="gd_code" dictText="gd_name" title="承建单位"></t:dictSelect>
				  <span class="Validform_checktip"></span>
				  <label class="Validform_label" style="display: none;">承建单位</label>
			  </td>

			  <td align="right">
				  <label class="Validform_label">
					  产品:
				  </label>
			  </td>
			  <td class="value">
				  <t:dictSelect field="by3" type="list"  typeGroupCode="kp_cp"    hasLabel="false"  title="产品名称" ></t:dictSelect>
				  <span class="Validform_checktip"></span>
				  <label class="Validform_label" style="display: none;">产品</label>
			  </td>
		  </tr>

				<tr>
					<td align="right">
						<label class="Validform_label">
							金额:
						</label>
					</td>
					<td class="value">
					     	 <input id="ysJine" name="ysJine" type="text" style="width: 150px" datatype="*"  class="inputxt"  ignore="checked" />
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">预收金额</label>
						</td>

					<td align="right">
						<label class="Validform_label">
							备注:
						</label>
					</td>
					<td class="value">
					     	 <input id="ysRemark" name="ysRemark" type="text" style="width: 150px" class="inputxt"  ignore="ignore" />
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">预收备注</label>
						</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							收款来源:
						</label>
					</td>
					<td class="value">
						<t:dictSelect field="ysFangshi" type="radio"  typeGroupCode="ys_fangshi"  defaultVal="${tKpYushouPage.ysFangshi}" hasLabel="false"  title="收款来源" ></t:dictSelect>
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">收款来源</label>
					</td>
					<td align="right">
						<label class="Validform_label">
							代码:
						</label>
					</td>
					<td class="value">
						<input id="by4" name="by4" type="text" style="width: 150px" class="inputxt"  ignore="ignore" />
						<span class="Validform_checktip"></span>
						<label class="Validform_label" style="display: none;">代码</label>
					</td>
				</tr>
				
			</table>
		</t:formvalid>
 </body>
  <script src = "webpage/com/yserp/kp/tKpYushou.js"></script>		
